class Iteration < ActiveRecord::Base
  set_table_name "iteration"
  set_primary_key "iteration_id"

  belongs_to :project,
             :class_name  => 'Project',
	     :foreign_key => 'project_fk';
  
  has_many :tasks,
           :class_name  => 'Task',
	   :foreign_key => 'iteration_fk';

  has_many :comments,
           :class_name  => 'Comment',
	   :foreign_key => 'iteration_fk';

  validates_presence_of :name, :description;	
 

  # get iteration
  # returns the iteration based on iteration id
  
  def self.get_iteration(iteration_id)
      return nil unless iteration_id; # sane verification
      return find(:first,
                  :conditions => ["iteration_id = ?", iteration_id]);
  end

end
